<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./lib/jquery.js"></script>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
      overflow: hidden;
    }

    #angel {
      position: absolute;
    }
  </style>
</head>

<body>
  <img src="./angel.gif" alt="" id="angel" />

  <script>
    $(function () {
      // ①准备阀门, 初始值为true
      let flag = true;

      $(document).on('mousemove', function (e) {
        // ②判断阀门是否是开着的
        if (flag == true) {

          $('#angel').css('top', e.pageY + 'px').css('left', e.pageX + 'px')
          console.log('ok')

          // ③关门
          flag = false

          // ④通过定时器, 一定时间之后开门
          setTimeout(() => {
            flag = true
          }, 20)
        }
      })
    })




  </script>
</body>

</html>